package com.jservice.web.smkAd;

import com.jservice.framework.annotation.RouteBind;
import com.jservice.framework.dto.Message;
import com.jservice.framework.dto.Pager;
import com.jservice.model.SmkAd;
import com.jservice.web.base.JBaseController;

/**
 * SmkBannerController - 广告
 *
 * @Author cwledit
 * @DATE 2017/7/10.
 */
@RouteBind(path = "/smk/ad")
public class SmkAdController extends JBaseController {

    public void list(){
        Pager pager = SmkAdService.me().findPage(getPageable());
        setAttr("pager",pager);
        render("list");
    }

    public void edit(){
        String adId = getPara("id");
        SmkAd ad = SmkAdService.me().findById(adId);
        setAttr("ad",ad);
        render("edit");
    }

    public void update(){

        SmkAd ad = getModel(SmkAd.class,"ad");
        if(SmkAdService.me().update(ad)){
            setFlashMessage(Message.success("修改成功"));
        }else{
            setFlashMessage(Message.error("修改失败"));
        }
        redirect("/smk/ad/list");
    }




}
